<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import BwipJs from 'bwip-js';
import { useRouter } from 'vue-router';
const router = useRouter()
const text = ref('45646546546')
const barcodeCanvasRef = ref('123456789012')

const generateBarcode = () => {
    BwipJs.toCanvas(barcodeCanvasRef.value, {
        bcid: 'code128',//条形码类型
        text: text.value,
        scale: 4,//缩放比例
        height: 10,//条形码高度
        // includecheck: true,//是否包含文本
        textxalign: 'center'//文本对齐方式
    })
}
onMounted(() => {
    generateBarcode()
})
</script>

<template>
    <canvas ref="barcodeCanvasRef" style="margin-top: 10px;"></canvas>
</template>

<style scoped></style>
